package com.aurora.app.entity;
import java.io.UnsupportedEncodingException;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Convert;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import org.apache.commons.codec.binary.Base64;
import org.hibernate.annotations.GenericGenerator;

import com.aurora.base.entity.BaseEntity;

@Entity
@Table(name="tb_user")
public class User extends BaseEntity {
	/**
	 * 手机号码
	 */
	private Long phone;
	/**
	 * 活跃积分
	 */
	private Float huoyueIntegral = 0F;
	/**
	 * 交易积分
	 */
	private Float jiaoyiIntegral = 0F;
	/**
	 * 发布数量
	 */
	private Integer issueNum = 0;
	
	/**
	 * 微信用户openid
	 */
	private String openid;

	/**
	 * 昵称
	 */
	private String nickName;

	/**
	 * 头像
	 */
	private String headimgurl;

	/**
	 * 是否已经关注
	 */
	private boolean subscribe;

	/**
	 * 性别
	 */
	private Integer sex ;

	/**
	 * 城市
	 */
	private String city;
	/**
	 * 省份
	 */
	private String province;
	/**
	 * 国家
	 */
	private String country;

	/**
	 * 语言
	 */
	private String language;
	
	
	
	@Column(name = "f_subscribe", columnDefinition = "INT(11) default 0")
	public boolean isSubscribe() {
		return this.subscribe;
	}
	public void setSubscribe(boolean subscribe) {
		this.subscribe = subscribe;
	}

	@Column(name = "f_sex")
	public Integer getSex() {
		return this.sex;
	}
	public void setSex(Integer sex) {
		this.sex = sex;
	}

	@Column(name = "f_city")
	public String getCity() {
		return this.city;
	}
	public void setCity(String city) {
		this.city = city;
	}

	@Column(name = "f_province")
	public String getProvince() {
		return this.province;
	}
	public void setProvince(String province) {
		this.province = province;
	}

	@Column(name = "f_country")
	public String getCountry() {
		return this.country;
	}
	public void setCountry(String country) {
		this.country = country;
	}

	@Column(name = "f_language")
	public String getLanguage() {
		return this.language;
	}
	public void setLanguage(String language) {
		this.language = language;
	}
	
	

	/**
	 * @return the headimgurl
	 */
	@Column(name = "f_head_img_url")
	public String getHeadimgurl() {
		return this.headimgurl;
	}
	/**
	 * @param headimgurl
	 *            the headimgurl to set
	 */
	public void setHeadimgurl(String headimgurl) {
		this.headimgurl = headimgurl;
	}

	
	
	
	@Column(name="f_phone")
	public Long getPhone() {
		return phone;
	}
	public void setPhone(Long phone) {
		this.phone = phone;
	}
	
	//发布数量
	@Column(name="f_issue_num")
	public Integer getIssueNum() {
		return issueNum;
	}
	public void setIssueNum(Integer issueNum) {
		this.issueNum = issueNum;
	}
	
	@Column(name="f_nickname")
	public String getNickName() {
		return this.nickName;
//		try {
//			return new String(Base64.decodeBase64(nickName.getBytes()), "UTF-8");
//		} catch (UnsupportedEncodingException e) {
//			return "昵称含有非法符号";
//		}
	}
	public void setNickName(String nickName) {
//			this.nickName = Base64.encodeBase64String(nickName.getBytes());
		this.nickName = nickName;
	}
	@Column(name = "f_openid")
	public String getOpenid() {
		return openid;
	}
	public void setOpenid(String openid) {
		this.openid = openid;
	}
	
	@Column(name="f_huoyue_integral")
	public Float getHuoyueIntegral() {
		return huoyueIntegral;
	}
	public void setHuoyueIntegral(Float huoyueIntegral) {
		this.huoyueIntegral = huoyueIntegral;
	}
	
	@Column(name="f_jiaoyi_integral")
	public Float getJiaoyiIntegral() {
		return jiaoyiIntegral;
	}
	public void setJiaoyiIntegral(Float jiaoyiIntegral) {
		this.jiaoyiIntegral = jiaoyiIntegral;
	}
}
